import requests
import execjs

with open('SZXCode.js','r',encoding='utf-8') as file:
    javaFile = file.read()

ctx = execjs.compile(javaFile)
EncKey = ctx.call('getResCode')

cookies = {
    'MALLSSID': '426470596C42456F374949384C306E6E2F63767641572B384842743267774644762B757A727553727259786D6C7637366C57344D546843363543376D79554E79',
    'Hm_lvt_489bd07e99fbfc5f12cbb4145adb0a9b': '1725875831,1725929227,1725932280',
    'HMACCOUNT': 'E3DA92CCA15F8725',
    'Hm_lpvt_489bd07e99fbfc5f12cbb4145adb0a9b': '1725942612',
}

headers = {
    'Accept': '*/*',
    # 'Accept-EncKey': '7IbAqmpNiG3birdcge1M1Q==',
    'Accept-EncKey': EncKey,
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    # 'Cookie': 'MALLSSID=426470596C42456F374949384C306E6E2F63767641572B384842743267774644762B757A727553727259786D6C7637366C57344D546843363543376D79554E79; Hm_lvt_489bd07e99fbfc5f12cbb4145adb0a9b=1725875831,1725929227,1725932280; HMACCOUNT=E3DA92CCA15F8725; Hm_lpvt_489bd07e99fbfc5f12cbb4145adb0a9b=1725942612',
    'Origin': 'http://webapi.cninfo.com.cn',
    'Referer': 'http://webapi.cninfo.com.cn/',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0',
    'X-Requested-With': 'XMLHttpRequest',
}

data = {
    'tdate': '2024-09-09',
    'scode': '399001',
}

response = requests.post(
    'http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1015',
    cookies=cookies,
    headers=headers,
    data=data,
    verify=False,
).json()
print(response)